﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Zerg
{
	public class ActionProduceZergling : ActionProduceFromLarva
	{
		public static ActionProduceZergling Instance = new ActionProduceZergling();
		private ActionProduceZergling() : base(24, 50, 0, 1) { }
		public override bool IsInvalid(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			return base.IsInvalid(bo) || state.SpawningPool.Total == 0;
		}
		public override bool HaveTechnology(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			return state.SpawningPool.Count > 0;
		}
		public override void OnProductionStarted(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			state.Zergling_Building += 2;
		}
		public override void OnProductionFinished(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			state.Zergling_Building -= 2;
			state.Zergling += 2;
		}
		public override string EventName { get { return "ActionSpawnZergling"; } }
		private IAction[,] m_Requirements;
		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
					m_Requirements = new IAction[,] { { ActionProduceSpawningPool.Instance } };
				return m_Requirements;
			}
		}
	}
}
